package com.aike.user_center_practice.exception;

import com.aike.user_center_practice.common.BaseResponse.ErrorCode;

/**
 * 定义自定义异常类
 * 原因：相较于JAVA的异常类，支持更多的异常类
 * 其次，自定义的异常类，更灵活/快捷使用
 */
public class BusinessException extends RuntimeException {

    private int code;

    private String description;

    public BusinessException(int code, String massage, String description) {
        super(massage);
        this.code = code;
        this.description = description;
    }

    public BusinessException(ErrorCode errorCode) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
        this.description = errorCode.getDescription();
    }

    public BusinessException(ErrorCode errorCode, String description) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }
}
